<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Stat1 extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $this->table('stat')
            //年
             ->addColumn('year', 'integer', ['limit' => 4, 'default' => 2024, "after" => 'purchase_order_quantity', 'comment' => '年'])
            //月
             ->addColumn('month', 'integer', ['limit' => 2, 'default' => 1, "after" => 'year', 'comment' => '月'])
            //季度
             ->addColumn('quarter', 'integer', ['limit' => 1, 'default' => 1, "after" => 'month', 'comment' => '季度'])
            //类型: 1:日,2:周,3:月,4:季,5:年
             ->addColumn('type', 'integer', ['limit' => 1, 'default' => 3, "after" => 'quarter', 'comment' => '类型: 1:日,2:周,3:月,4:季,5:年'])

             ->update();
    }
}
